package com.graph;

import java.util.TreeMap;
import java.util.TreeSet;

/**
 *code_repository_delta
 *@author huliangjun
 *@date 2018/11/30 11:25
 */

public class Test {
    public static void main(String[] args) {

        //构建图
        MapGraph graph=new MapGraph();
        graph.addEdge("p0","p1").addJumpPoint(new JumpPoint(100d,200d,1));;
        graph.addEdge("p1","p0").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p2","p0").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p3","p0").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p2","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","p2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p3","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","p3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","p0").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","p0").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","p7").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","p8").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","p6").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","p6").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","p7").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","p8").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p7","p6").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p7","p4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p7","p2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p8","p6").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p8","p5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p8","p3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p3","b1").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","b1").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p1","b2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p1","b2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","b2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p5","b2").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","b3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","b3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","b3").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","b4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p6","b4").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","b5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p0","b5").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p2","b6").addJumpPoint(new JumpPoint(100d,200d,1));
        graph.addEdge("p4","b6").addJumpPoint(new JumpPoint(100d,200d,1));
        //以v3为起点计算无权图的最短路径
        graph.unweighted("p0");
        //打印从v3到各个顶点的最短路径
        System.out.println("The shortest path from p0:");
//        for(int i=1;i<=8;i++){
//            List<String> pathList = graph.printPath("p0","p"+i);
        TreeMap<Integer, TreeSet<JumpPoint>> pathList = graph.calculatorPath("b4");
//            System.out.println(pathList);
//        }
    }

    public void test1(){
        MapGraph graph=new MapGraph();
        graph.addEdge("v1", "v2");
        graph.addEdge("v1", "v4");
        graph.addEdge("v2", "v4");
        graph.addEdge("v2", "v1");
        graph.addEdge("v2", "v5");
        graph.addEdge("v3", "v1");
        graph.addEdge("v3", "v4");
        graph.addEdge("v3", "v6");
        graph.addEdge("v4", "v3");
        graph.addEdge("v4", "v1");
        graph.addEdge("v4", "v5");
        graph.addEdge("v4", "v7");
        graph.addEdge("v5", "v7");
        graph.addEdge("v7", "v6");
        graph.addEdge("v6", "v7");

        //以v3为起点计算无权图的最短路径
        graph.unweighted("v3");
        //打印从v3到各个顶点的最短路径
        System.out.println("The shortest path from v3:");
//        for(int i=1;i<=7;i++){
//            graph.printPath("v"+i);
//        }
    }
}
